<?php

/**
 * Transaction.
 *
 * PHP version 8.3
 *
 * @category Class
 *
 * @author   OpenAPI Generator team
 *
 * @see     https://openapi-generator.tech
 */

/**
 * The Selling Partner API for Amazon Seller Wallet Open Banking API.
 *
 * The Selling Partner API for Seller Wallet (Seller Wallet API) provides financial information that is relevant to a seller's Seller Wallet account. You can obtain financial events, balances, and transfer schedules for Seller Wallet accounts. You can also schedule and initiate transactions.
 *
 * The version of the OpenAPI document: 2024-03-01
 * Generated by: https://openapi-generator.tech
 * Generator version: 7.9.0
 */

/**
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */

namespace SpApi\Model\sellerWallet\v2024_03_01;

use SpApi\Model\ModelInterface;
use SpApi\ObjectSerializer;

/**
 * Transaction Class Doc Comment.
 *
 * @category Class
 *
 * @description The current transaction status and related historical details.
 *
 * @author   OpenAPI Generator team
 *
 * @see     https://openapi-generator.tech
 *
 * @implements \ArrayAccess<string, mixed>
 */
class Transaction implements ModelInterface, \ArrayAccess, \JsonSerializable
{
    public const DISCRIMINATOR = null;

    /**
     * The original name of the model.
     */
    protected static string $openAPIModelName = 'Transaction';

    /**
     * Array of property to type mappings. Used for (de)serialization.
     *
     * @var string[]
     */
    protected static array $openAPITypes = [
        'transaction_id' => 'string',
        'transaction_type' => '\SpApi\Model\sellerWallet\v2024_03_01\TransactionType',
        'transaction_status' => '\SpApi\Model\sellerWallet\v2024_03_01\TransactionStatus',
        'transaction_request_date' => '\DateTime',
        'expected_completion_date' => '\DateTime',
        'transaction_actual_completion_date' => '\DateTime',
        'last_update_date' => '\DateTime',
        'requester_name' => 'string',
        'transaction_requester_source' => 'string',
        'transaction_description' => 'string',
        'transaction_source_account' => '\SpApi\Model\sellerWallet\v2024_03_01\TransactionAccount',
        'transaction_destination_account' => '\SpApi\Model\sellerWallet\v2024_03_01\TransactionAccount',
        'transaction_request_amount' => '\SpApi\Model\sellerWallet\v2024_03_01\Currency',
        'transfer_rate_details' => '\SpApi\Model\sellerWallet\v2024_03_01\TransferRatePreview',
        'transaction_final_amount' => '\SpApi\Model\sellerWallet\v2024_03_01\Currency',
        'transaction_failure_reason' => 'string'];

    /**
     * Array of property to format mappings. Used for (de)serialization.
     *
     * @var string[]
     *
     * @phpstan-var array<string, string|null>
     *
     * @psalm-var array<string, string|null>
     */
    protected static array $openAPIFormats = [
        'transaction_id' => null,
        'transaction_type' => null,
        'transaction_status' => null,
        'transaction_request_date' => 'date-time',
        'expected_completion_date' => 'date-time',
        'transaction_actual_completion_date' => 'date-time',
        'last_update_date' => 'date-time',
        'requester_name' => null,
        'transaction_requester_source' => null,
        'transaction_description' => null,
        'transaction_source_account' => null,
        'transaction_destination_account' => null,
        'transaction_request_amount' => null,
        'transfer_rate_details' => null,
        'transaction_final_amount' => null,
        'transaction_failure_reason' => null];

    /**
     * Array of nullable properties. Used for (de)serialization.
     *
     * @var bool[]
     */
    protected static array $openAPINullables = [
        'transaction_id' => false,
        'transaction_type' => false,
        'transaction_status' => false,
        'transaction_request_date' => false,
        'expected_completion_date' => true,
        'transaction_actual_completion_date' => true,
        'last_update_date' => false,
        'requester_name' => true,
        'transaction_requester_source' => false,
        'transaction_description' => false,
        'transaction_source_account' => false,
        'transaction_destination_account' => false,
        'transaction_request_amount' => false,
        'transfer_rate_details' => false,
        'transaction_final_amount' => true,
        'transaction_failure_reason' => true,
    ];

    /**
     * If a nullable field gets set to null, insert it here.
     *
     * @var bool[]
     */
    protected array $openAPINullablesSetToNull = [];

    /**
     * Array of attributes where the key is the local name,
     * and the value is the original name.
     *
     * @var string[]
     */
    protected static array $attributeMap = [
        'transaction_id' => 'transactionId',
        'transaction_type' => 'transactionType',
        'transaction_status' => 'transactionStatus',
        'transaction_request_date' => 'transactionRequestDate',
        'expected_completion_date' => 'expectedCompletionDate',
        'transaction_actual_completion_date' => 'transactionActualCompletionDate',
        'last_update_date' => 'lastUpdateDate',
        'requester_name' => 'requesterName',
        'transaction_requester_source' => 'transactionRequesterSource',
        'transaction_description' => 'transactionDescription',
        'transaction_source_account' => 'transactionSourceAccount',
        'transaction_destination_account' => 'transactionDestinationAccount',
        'transaction_request_amount' => 'transactionRequestAmount',
        'transfer_rate_details' => 'transferRateDetails',
        'transaction_final_amount' => 'transactionFinalAmount',
        'transaction_failure_reason' => 'transactionFailureReason',
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses).
     *
     * @var string[]
     */
    protected static array $setters = [
        'transaction_id' => 'setTransactionId',
        'transaction_type' => 'setTransactionType',
        'transaction_status' => 'setTransactionStatus',
        'transaction_request_date' => 'setTransactionRequestDate',
        'expected_completion_date' => 'setExpectedCompletionDate',
        'transaction_actual_completion_date' => 'setTransactionActualCompletionDate',
        'last_update_date' => 'setLastUpdateDate',
        'requester_name' => 'setRequesterName',
        'transaction_requester_source' => 'setTransactionRequesterSource',
        'transaction_description' => 'setTransactionDescription',
        'transaction_source_account' => 'setTransactionSourceAccount',
        'transaction_destination_account' => 'setTransactionDestinationAccount',
        'transaction_request_amount' => 'setTransactionRequestAmount',
        'transfer_rate_details' => 'setTransferRateDetails',
        'transaction_final_amount' => 'setTransactionFinalAmount',
        'transaction_failure_reason' => 'setTransactionFailureReason',
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests).
     *
     * @var string[]
     */
    protected static array $getters = [
        'transaction_id' => 'getTransactionId',
        'transaction_type' => 'getTransactionType',
        'transaction_status' => 'getTransactionStatus',
        'transaction_request_date' => 'getTransactionRequestDate',
        'expected_completion_date' => 'getExpectedCompletionDate',
        'transaction_actual_completion_date' => 'getTransactionActualCompletionDate',
        'last_update_date' => 'getLastUpdateDate',
        'requester_name' => 'getRequesterName',
        'transaction_requester_source' => 'getTransactionRequesterSource',
        'transaction_description' => 'getTransactionDescription',
        'transaction_source_account' => 'getTransactionSourceAccount',
        'transaction_destination_account' => 'getTransactionDestinationAccount',
        'transaction_request_amount' => 'getTransactionRequestAmount',
        'transfer_rate_details' => 'getTransferRateDetails',
        'transaction_final_amount' => 'getTransactionFinalAmount',
        'transaction_failure_reason' => 'getTransactionFailureReason',
    ];

    /**
     * Associative array for storing property values.
     */
    protected array $container = [];

    /**
     * Constructor.
     *
     * @param null|array $data Associated array of property values
     *                         initializing the model
     */
    public function __construct(?array $data = null)
    {
        $this->setIfExists('transaction_id', $data ?? [], null);
        $this->setIfExists('transaction_type', $data ?? [], null);
        $this->setIfExists('transaction_status', $data ?? [], null);
        $this->setIfExists('transaction_request_date', $data ?? [], null);
        $this->setIfExists('expected_completion_date', $data ?? [], null);
        $this->setIfExists('transaction_actual_completion_date', $data ?? [], null);
        $this->setIfExists('last_update_date', $data ?? [], null);
        $this->setIfExists('requester_name', $data ?? [], null);
        $this->setIfExists('transaction_requester_source', $data ?? [], null);
        $this->setIfExists('transaction_description', $data ?? [], null);
        $this->setIfExists('transaction_source_account', $data ?? [], null);
        $this->setIfExists('transaction_destination_account', $data ?? [], null);
        $this->setIfExists('transaction_request_amount', $data ?? [], null);
        $this->setIfExists('transfer_rate_details', $data ?? [], null);
        $this->setIfExists('transaction_final_amount', $data ?? [], null);
        $this->setIfExists('transaction_failure_reason', $data ?? [], null);
    }

    /**
     * Gets the string presentation of the object.
     *
     * @return string
     */
    public function __toString()
    {
        return json_encode(
            ObjectSerializer::sanitizeForSerialization($this),
            JSON_PRETTY_PRINT
        );
    }

    /**
     * Array of property to type mappings. Used for (de)serialization.
     */
    public static function openAPITypes(): array
    {
        return self::$openAPITypes;
    }

    /**
     * Array of property to format mappings. Used for (de)serialization.
     */
    public static function openAPIFormats(): array
    {
        return self::$openAPIFormats;
    }

    /**
     * Checks if a property is nullable.
     */
    public static function isNullable(string $property): bool
    {
        return self::openAPINullables()[$property] ?? false;
    }

    /**
     * Checks if a nullable property is set to null.
     */
    public function isNullableSetToNull(string $property): bool
    {
        return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
    }

    /**
     * Array of attributes where the key is the local name,
     * and the value is the original name.
     */
    public static function attributeMap(): array
    {
        return self::$attributeMap;
    }

    /**
     * Array of attributes to setter functions (for deserialization of responses).
     */
    public static function setters(): array
    {
        return self::$setters;
    }

    /**
     * Array of attributes to getter functions (for serialization of requests).
     */
    public static function getters(): array
    {
        return self::$getters;
    }

    /**
     * The original name of the model.
     */
    public function getModelName(): string
    {
        return self::$openAPIModelName;
    }

    /**
     * Show all the invalid properties with reasons.
     *
     * @return array invalid properties with reasons
     */
    public function listInvalidProperties(): array
    {
        $invalidProperties = [];

        if (null === $this->container['transaction_id']) {
            $invalidProperties[] = "'transaction_id' can't be null";
        }
        if (null === $this->container['transaction_type']) {
            $invalidProperties[] = "'transaction_type' can't be null";
        }
        if (null === $this->container['transaction_status']) {
            $invalidProperties[] = "'transaction_status' can't be null";
        }
        if (null === $this->container['transaction_request_date']) {
            $invalidProperties[] = "'transaction_request_date' can't be null";
        }
        if (null === $this->container['last_update_date']) {
            $invalidProperties[] = "'last_update_date' can't be null";
        }
        if (null === $this->container['transaction_requester_source']) {
            $invalidProperties[] = "'transaction_requester_source' can't be null";
        }
        if (null === $this->container['transaction_description']) {
            $invalidProperties[] = "'transaction_description' can't be null";
        }
        if (null === $this->container['transaction_source_account']) {
            $invalidProperties[] = "'transaction_source_account' can't be null";
        }
        if (null === $this->container['transaction_destination_account']) {
            $invalidProperties[] = "'transaction_destination_account' can't be null";
        }
        if (null === $this->container['transaction_request_amount']) {
            $invalidProperties[] = "'transaction_request_amount' can't be null";
        }
        if (null === $this->container['transfer_rate_details']) {
            $invalidProperties[] = "'transfer_rate_details' can't be null";
        }

        return $invalidProperties;
    }

    /**
     * Validate all the properties in the model
     * return true if all passed.
     *
     * @return bool True if all properties are valid
     */
    public function valid(): bool
    {
        return 0 === count($this->listInvalidProperties());
    }

    /**
     * Gets transaction_id.
     */
    public function getTransactionId(): string
    {
        return $this->container['transaction_id'];
    }

    /**
     * Sets transaction_id.
     *
     * @param string $transaction_id The unique identifier provided by Amazon to the transaction
     */
    public function setTransactionId(string $transaction_id): self
    {
        if (is_null($transaction_id)) {
            throw new \InvalidArgumentException('non-nullable transaction_id cannot be null');
        }
        $this->container['transaction_id'] = $transaction_id;

        return $this;
    }

    /**
     * Gets transaction_type.
     */
    public function getTransactionType(): string
    {
        return $this->container['transaction_type'];
    }

    /**
     * Sets transaction_type.
     *
     * @param string $transaction_type transaction_type
     */
    public function setTransactionType(string $transaction_type): self
    {
        if (is_null($transaction_type)) {
            throw new \InvalidArgumentException('non-nullable transaction_type cannot be null');
        }
        $this->container['transaction_type'] = $transaction_type;

        return $this;
    }

    /**
     * Gets transaction_status.
     */
    public function getTransactionStatus(): string
    {
        return $this->container['transaction_status'];
    }

    /**
     * Sets transaction_status.
     *
     * @param string $transaction_status transaction_status
     */
    public function setTransactionStatus(string $transaction_status): self
    {
        if (is_null($transaction_status)) {
            throw new \InvalidArgumentException('non-nullable transaction_status cannot be null');
        }
        $this->container['transaction_status'] = $transaction_status;

        return $this;
    }

    /**
     * Gets transaction_request_date.
     */
    public function getTransactionRequestDate(): \DateTime
    {
        return $this->container['transaction_request_date'];
    }

    /**
     * Sets transaction_request_date.
     *
     * @param \DateTime $transaction_request_date the date when the transaction was initiated
     */
    public function setTransactionRequestDate(\DateTime $transaction_request_date): self
    {
        if (is_null($transaction_request_date)) {
            throw new \InvalidArgumentException('non-nullable transaction_request_date cannot be null');
        }
        $this->container['transaction_request_date'] = $transaction_request_date;

        return $this;
    }

    /**
     * Gets expected_completion_date.
     */
    public function getExpectedCompletionDate(): ?\DateTime
    {
        return $this->container['expected_completion_date'];
    }

    /**
     * Sets expected_completion_date.
     *
     * @param null|\DateTime $expected_completion_date Expected completion date of a transaction, for existing active Payees (Trusted Beneficiaries) it will be 24 hours but for new destination bank accounts the value could go up to 5 days
     */
    public function setExpectedCompletionDate(?\DateTime $expected_completion_date): self
    {
        if (is_null($expected_completion_date)) {
            array_push($this->openAPINullablesSetToNull, 'expected_completion_date');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('expected_completion_date', $nullablesSetToNull);
            if (false !== $index) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }
        $this->container['expected_completion_date'] = $expected_completion_date;

        return $this;
    }

    /**
     * Gets transaction_actual_completion_date.
     */
    public function getTransactionActualCompletionDate(): ?\DateTime
    {
        return $this->container['transaction_actual_completion_date'];
    }

    /**
     * Sets transaction_actual_completion_date.
     *
     * @param null|\DateTime $transaction_actual_completion_date Transaction completion date
     */
    public function setTransactionActualCompletionDate(?\DateTime $transaction_actual_completion_date): self
    {
        if (is_null($transaction_actual_completion_date)) {
            array_push($this->openAPINullablesSetToNull, 'transaction_actual_completion_date');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('transaction_actual_completion_date', $nullablesSetToNull);
            if (false !== $index) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }
        $this->container['transaction_actual_completion_date'] = $transaction_actual_completion_date;

        return $this;
    }

    /**
     * Gets last_update_date.
     */
    public function getLastUpdateDate(): \DateTime
    {
        return $this->container['last_update_date'];
    }

    /**
     * Sets last_update_date.
     *
     * @param \DateTime $last_update_date The last update date on the transaction
     */
    public function setLastUpdateDate(\DateTime $last_update_date): self
    {
        if (is_null($last_update_date)) {
            throw new \InvalidArgumentException('non-nullable last_update_date cannot be null');
        }
        $this->container['last_update_date'] = $last_update_date;

        return $this;
    }

    /**
     * Gets requester_name.
     */
    public function getRequesterName(): ?string
    {
        return $this->container['requester_name'];
    }

    /**
     * Sets requester_name.
     *
     * @param null|string $requester_name Amazon SW customer who requested the transaction
     */
    public function setRequesterName(?string $requester_name): self
    {
        if (is_null($requester_name)) {
            array_push($this->openAPINullablesSetToNull, 'requester_name');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('requester_name', $nullablesSetToNull);
            if (false !== $index) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }
        $this->container['requester_name'] = $requester_name;

        return $this;
    }

    /**
     * Gets transaction_requester_source.
     */
    public function getTransactionRequesterSource(): string
    {
        return $this->container['transaction_requester_source'];
    }

    /**
     * Sets transaction_requester_source.
     *
     * @param string $transaction_requester_source The transaction initiation source. This value is either the Amazon portal or PISP name that the customer used to start the transaction.
     */
    public function setTransactionRequesterSource(string $transaction_requester_source): self
    {
        if (is_null($transaction_requester_source)) {
            throw new \InvalidArgumentException('non-nullable transaction_requester_source cannot be null');
        }
        $this->container['transaction_requester_source'] = $transaction_requester_source;

        return $this;
    }

    /**
     * Gets transaction_description.
     */
    public function getTransactionDescription(): string
    {
        return $this->container['transaction_description'];
    }

    /**
     * Sets transaction_description.
     *
     * @param string $transaction_description a description of the transaction that the requester provides when they initiate the transaction
     */
    public function setTransactionDescription(string $transaction_description): self
    {
        if (is_null($transaction_description)) {
            throw new \InvalidArgumentException('non-nullable transaction_description cannot be null');
        }
        $this->container['transaction_description'] = $transaction_description;

        return $this;
    }

    /**
     * Gets transaction_source_account.
     */
    public function getTransactionSourceAccount(): TransactionAccount
    {
        return $this->container['transaction_source_account'];
    }

    /**
     * Sets transaction_source_account.
     *
     * @param TransactionAccount $transaction_source_account transaction_source_account
     */
    public function setTransactionSourceAccount(TransactionAccount $transaction_source_account): self
    {
        if (is_null($transaction_source_account)) {
            throw new \InvalidArgumentException('non-nullable transaction_source_account cannot be null');
        }
        $this->container['transaction_source_account'] = $transaction_source_account;

        return $this;
    }

    /**
     * Gets transaction_destination_account.
     */
    public function getTransactionDestinationAccount(): TransactionAccount
    {
        return $this->container['transaction_destination_account'];
    }

    /**
     * Sets transaction_destination_account.
     *
     * @param TransactionAccount $transaction_destination_account transaction_destination_account
     */
    public function setTransactionDestinationAccount(TransactionAccount $transaction_destination_account): self
    {
        if (is_null($transaction_destination_account)) {
            throw new \InvalidArgumentException('non-nullable transaction_destination_account cannot be null');
        }
        $this->container['transaction_destination_account'] = $transaction_destination_account;

        return $this;
    }

    /**
     * Gets transaction_request_amount.
     */
    public function getTransactionRequestAmount(): Currency
    {
        return $this->container['transaction_request_amount'];
    }

    /**
     * Sets transaction_request_amount.
     *
     * @param Currency $transaction_request_amount transaction_request_amount
     */
    public function setTransactionRequestAmount(Currency $transaction_request_amount): self
    {
        if (is_null($transaction_request_amount)) {
            throw new \InvalidArgumentException('non-nullable transaction_request_amount cannot be null');
        }
        $this->container['transaction_request_amount'] = $transaction_request_amount;

        return $this;
    }

    /**
     * Gets transfer_rate_details.
     */
    public function getTransferRateDetails(): TransferRatePreview
    {
        return $this->container['transfer_rate_details'];
    }

    /**
     * Sets transfer_rate_details.
     *
     * @param TransferRatePreview $transfer_rate_details transfer_rate_details
     */
    public function setTransferRateDetails(TransferRatePreview $transfer_rate_details): self
    {
        if (is_null($transfer_rate_details)) {
            throw new \InvalidArgumentException('non-nullable transfer_rate_details cannot be null');
        }
        $this->container['transfer_rate_details'] = $transfer_rate_details;

        return $this;
    }

    /**
     * Gets transaction_final_amount.
     */
    public function getTransactionFinalAmount(): ?Currency
    {
        return $this->container['transaction_final_amount'];
    }

    /**
     * Sets transaction_final_amount.
     *
     * @param null|Currency $transaction_final_amount transaction_final_amount
     */
    public function setTransactionFinalAmount(?Currency $transaction_final_amount): self
    {
        if (is_null($transaction_final_amount)) {
            array_push($this->openAPINullablesSetToNull, 'transaction_final_amount');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('transaction_final_amount', $nullablesSetToNull);
            if (false !== $index) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }
        $this->container['transaction_final_amount'] = $transaction_final_amount;

        return $this;
    }

    /**
     * Gets transaction_failure_reason.
     */
    public function getTransactionFailureReason(): ?string
    {
        return $this->container['transaction_failure_reason'];
    }

    /**
     * Sets transaction_failure_reason.
     *
     * @param null|string $transaction_failure_reason Description in case the transaction fails before completion
     */
    public function setTransactionFailureReason(?string $transaction_failure_reason): self
    {
        if (is_null($transaction_failure_reason)) {
            array_push($this->openAPINullablesSetToNull, 'transaction_failure_reason');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('transaction_failure_reason', $nullablesSetToNull);
            if (false !== $index) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }
        $this->container['transaction_failure_reason'] = $transaction_failure_reason;

        return $this;
    }

    /**
     * Returns true if offset exists. False otherwise.
     *
     * @param int $offset Offset
     */
    public function offsetExists($offset): bool
    {
        return isset($this->container[$offset]);
    }

    /**
     * Gets offset.
     *
     * @param int $offset Offset
     *
     * @return null|mixed
     */
    #[\ReturnTypeWillChange]
    public function offsetGet($offset): mixed
    {
        return $this->container[$offset] ?? null;
    }

    /**
     * Sets value based on offset.
     *
     * @param null|int $offset Offset
     * @param mixed    $value  Value to be set
     */
    public function offsetSet($offset, mixed $value): void
    {
        if (is_null($offset)) {
            $this->container[] = $value;
        } else {
            $this->container[$offset] = $value;
        }
    }

    /**
     * Unsets offset.
     *
     * @param int $offset Offset
     */
    public function offsetUnset($offset): void
    {
        unset($this->container[$offset]);
    }

    /**
     * Serializes the object to a value that can be serialized natively by json_encode().
     *
     * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php
     *
     * @return mixed returns data which can be serialized by json_encode(), which is a value
     *               of any type other than a resource
     */
    #[\ReturnTypeWillChange]
    public function jsonSerialize(): mixed
    {
        return ObjectSerializer::sanitizeForSerialization($this);
    }

    /**
     * Gets a header-safe presentation of the object.
     */
    public function toHeaderValue(): string
    {
        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
    }

    /**
     * Array of nullable properties.
     */
    protected static function openAPINullables(): array
    {
        return self::$openAPINullables;
    }

    /**
     * Array of nullable field names deliberately set to null.
     *
     * @return bool[]
     */
    private function getOpenAPINullablesSetToNull(): array
    {
        return $this->openAPINullablesSetToNull;
    }

    /**
     * Setter - Array of nullable field names deliberately set to null.
     *
     * @param bool[] $openAPINullablesSetToNull
     */
    private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
    {
        $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
    }

    /**
     * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
     * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
     * $this->openAPINullablesSetToNull array.
     *
     * @param mixed $defaultValue
     */
    private function setIfExists(string $variableName, array $fields, $defaultValue): void
    {
        if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
            $this->openAPINullablesSetToNull[] = $variableName;
        }

        $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
    }
}
